<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html">



    <body>

        <ui:composition template="../templates/default3.xhtml">         

            <ui:define name="content">

                <h:form id="updateEmployee" binding="#{employeeManagerBean.loadUpdateEmployee}">


                    <p:panel header="Employee account information" id="employeeinfoPanel">

                        <font class="fieldNote"><b>* - Mandatory Field</b></font>
                        <p:messages/>
                        <br/>

                        <table>

                            <tr>

                                <td width="145">User ID:</td>
                                <td width="220"> <b><h:outputText  id="userId" value="#{employeeManagerBean.userId}" /> </b>

                                </td>
                                <td width="120">Password expiry:</td>
                                <td><h:outputText id ="passwordExpiry" value="#{employeeManagerBean.passwordExpiry}"  ><f:convertDateTime pattern="dd-MMM-yyyy"/></h:outputText></td>
                            </tr>      

                            <tr>
                                <td>Employee Name:</td>
                                <td> 
                                    <p:inputText required="true" requiredMessage="Employee Name Required"  id="name" value="#{employeeManagerBean.name}"> 

                                    </p:inputText> 
                                    <font class="fieldNote">*</font>
                                </td>
                                <td></td>
                                <td>
                                    <p:commandButton id="btnReset" 
                                                     value ="Reset password" ajax="true" update="passwordExpiry" 
                                                     actionListener="#{employeeManagerBean.resetPassword}" />

                                </td>
                            </tr>
                            <tr>
                                <td>D.O.B:</td>
                                <td> 
                                    <p:inputMask label ="D.O.B " required="true" requiredMessage="Date of Birth Required" validatorMessage="Invalid D.O.B format" mask="99/99/9999"  value="#{employeeManagerBean.dob}">
                                        <!--  <f:validateRegex pattern="(0?[1-9]|[12][0-9]|3[01])/(0?[1-9]|1[012])/((19|20)\\d\\d)" />  -->
                                    </p:inputMask> 

                                    <font class="fieldNote">(dd/mm/yyyy)</font>
                                    <font class="fieldNote">*</font>
                                </td>
                                <td>
                                    Active account:</td>
                                <td><h:selectOneMenu id="accountStatus" value="#{employeeManagerBean.accountStatus}">
                                        <f:selectItem id="ACTIVE" itemLabel="ACTIVE" itemValue="ACTIVE" />
                                        <f:selectItem id="LOCK" itemLabel="LOCK" itemValue="LOCK" />                                    
                                    </h:selectOneMenu></td>
                            </tr>

                            <tr>
                                <td>Department:</td>
                                <td>                                                                                
                                    <h:selectOneMenu id="department" value="#{employeeManagerBean.department}">                                                                                              <f:selectItem id="Wholesales" itemLabel="Sales - Wholesales" itemValue="Sales - Wholesales" />
                                        <f:selectItem id="Directsales" itemLabel="Sales - Direct sales" itemValue="Sales - Direct sales" />
                                        <f:selectItem id="Mktcampaign" itemLabel="Marketing - Marketing campaign" itemValue="Marketing - Marketing campaign" />
                                        <f:selectItem id="MktMM" itemLabel="Marketing - Mass media advertising" itemValue="Marketing - Mass media advertising" />
                                        <f:selectItem id="MktNM" itemLabel="Marketing - New and social media adverting" itemValue="Marketing - New and social media adverting" />
                                        <f:selectItem id="Prodsp" itemLabel="Production and Operation - sales planning" itemValue="Production and Operation - sales planning" />
                                        <f:selectItem id="Prodpp" itemLabel="Production and Operation - production planning" itemValue="Production and Operation - production planning" />
                                        <f:selectItem id="Proff" itemLabel="Production and Operation - factory floor" itemValue="Production and Operation - factory floor" />                                       
                                        <f:selectItem id="scw" itemLabel="Supply chain - Warehouse" itemValue="Supply chain - Warehouse" />
                                        <f:selectItem id="scship" itemLabel="Supply chain - Shipping" itemValue="Supply chain - Shipping" />
                                        <f:selectItem id="scpurch" itemLabel="Supply chain - Purchasing" itemValue="Supply chain - Purchasing" />
                                        <f:selectItem id="finar" itemLabel="Finance - Accounts receivable" itemValue="Fiance - Accounts receivable" />                                        
                                        <f:selectItem id="finap" itemLabel="Finance - Accounts payable" itemValue="Finance - Accounts payable" />                                       
                                        <f:selectItem id="finia" itemLabel="Finance - Internal audit" itemValue="Finance - Internal audit" />                                        
                                        <f:selectItem id="techtc" itemLabel="Technology - Technical support" itemValue="Technology - Technical support" />             
                                        <f:selectItem id="techad" itemLabel="Technology - Application Development" itemValue="Technology - Application Development" />                                   
                                    </h:selectOneMenu>

                                </td>
                                <td></td>
                            </tr>

                            <tr>
                                <td>Designation:</td>
                                <td> <p:inputText id="designation" value="#{employeeManagerBean.designation}"> 

                                    </p:inputText> 
                                    <font class="fieldNote">*</font>
                                </td>
                                <td></td><td></td>
                            </tr>

                            <tr>
                                <td>Contact No. (Office):</td>
                                <td><p:inputText label ="Contact No. (Office)" id="contactOffice" value="#{employeeManagerBean.contactOffice}" validatorMessage="Contact No. (Office) Must Have a Minimum of 8 Digits"> 
                                        <f:validateLength minimum="8"/>
                                    </p:inputText>
                                    <font class="fieldNote">* Min. 8</font>

                                </td>
                            </tr>
                            <tr>
                                <td>Contact No. (Mobile):</td>
                                <td>
                                    <p:inputText label="Contact No. (Mobile " id="contactMobile" value="#{employeeManagerBean.contactMobile}" validatorMessage="Contact No. (Mobile) Must Have a Minimum of 8 Digits"> 
                                        <f:validateLength minimum="8"/>
                                    </p:inputText>  
                                    <font class="fieldNote">* Min. 8</font>

                                </td>
                                <td></td><td></td>
                            </tr>

                            <tr>
                                <td>Email Address:</td>
                                <td>
                                    <p:inputText label="Email Address" id="email" requiredMessage="Email Address Required" validatorMessage="Invaild Email Address Format" value="#{employeeManagerBean.emailAddress}" > 
                                        <f:validateRegex pattern="^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}$" />    
                                    </p:inputText> 
                                    <font class="fieldNote">*</font>
                                </td>
                                <td></td><td></td>
                            </tr>
                            <tr>
                                <td>

                                </td>
                                <td><br/>
                                    <font size ="1">

                                        <h:commandLink id="EmployeeWelcome"  actionListener="#{reportManagerBean.getReports}" target="_blank">
                                            <h:outputText value="+ Welcome Letter"/>
                                        </h:commandLink><br/>
                                        
                                   
                                        
                                    </font>
                                    <br/>

                                    <br/>
                                </td>
                            </tr>


                            <tr >
                                <td></td>
                                <td>




                                </td>
                                <td></td><td></td>
                            </tr>


                        </table>
                        <br/>   
                        <hr/>
                        <center>
                            <p:commandButton id="btnDone" value="Done" actionListener="#{employeeManagerBean.doneUpdate}" ajax="true" update="updateEmployee"/>
&nbsp;&nbsp;&nbsp;
                            <p:commandButton value="Remove" onclick="confirmation.show()" />

                            <p:confirmDialog message="Are you sure about removing this user?"
                                             header="Remove User" severity="alert" widgetVar="confirmation">

                                
                                 

                                <table width="100%">
                                            <tr>
                                                <td align="center">
                                                    <p:commandButton value="Yes" oncomplete="confirmation.hide()"  actionListener="#{employeeManagerBean.removeUser}" />
                                        &nbsp;&nbsp;&nbsp;<p:commandButton value="No" onclick="confirmation.hide()" />
                                                </td>
                                            </tr>
                                        </table>
                                
                            </p:confirmDialog>
                        </center>
                    </p:panel>
                </h:form>
            </ui:define>        

        </ui:composition>

    </body>

</html>
